<template>
  <div id="app">
    <button @click="add">add</button>
    <button @click="update">update</button>
    <button @click="lock">lock</button>
    <button @click="unlock">unlock</button>

    <ul>
      <li v-for="issue in issues" :key="issue.id">
        <a href="javascript:;">{{ issue.title }}</a>
      </li>
    </ul>
  </div>
</template>

<script>
import {getIssues,addIssues,updateIssues,lockIssues,unlockIssues} from './api/github';
// import  {getContact} from './api/contact';
export default {
  name: 'App',
  data() {
    return {
      issues: [],
    };
  },
  methods: {
    async add() {
      //为一个指定的仓库去新增一个issue
      await addIssues({title: 'damu拔牙记', body: '一个牙上十个洞'});
    },

    async update() {
      //修改指定仓库的issue
      await updateIssues({id:"369",title:"damu666"});
    },

    async lock() {
      await lockIssues({id:"369",lock_reason:"too heated"});
    },

    async unlock() {
      await unlockIssues("369");
    },
  },
  async mounted() {
    //get请求:  查询一个指定用户的指定仓库的所有issues
    const issues = await getIssues();
    this.issues = issues;

    //get请求: 查询所有的联系人列表
    /*const { data:contactList } = await getContact();
    console.log(contactList);*/

    // const [{data:issues}] = await Promise.all([getIssues(),getContact()]);
    // this.issues = issues;
   },
};
</script>

<style scoped></style>
